package com.cqgc.mapper;

import com.cqgc.pojo.dto.OrderDTO.OrderQueryDTO;
import com.cqgc.pojo.entity.Order;
import com.cqgc.pojo.entity.OrderQuery;
import com.cqgc.pojo.entity.User;
import com.cqgc.pojo.vo.OrderDeliveryVO;
import com.github.pagehelper.Page;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    /**
     * 添加订单
     *
     * @param orders
     */
    void add(List<Order> orders);

    @Delete("delete from `order` where oid = #{oid}")
    void delete(int oid);

    /**
     * 根据订单号查询订单
     *
     * @param orderNumber
     * @return
     */
    @Select("select * from `order` where order_number = #{orderNumber}")
    Order findById(String orderNumber);

    /**
     * 修改订单状态
     *
     * @param order
     */
    @Update("update `order` set status = #{status} where order_number = #{orderNumber}")
    void updateStatus(Order order);

    /**
     * 根据供应商id查询订单
     *
     * @param providerId
     * @return
     */

    List<Order> findByProviderId(int providerId, Integer status);

    /**
     * 根据消费者id查询订单
     *
     * @param consumerId
     * @return
     */
    @Select("select * from `order` where consumer_id = #{consumerId}")
    List<Order> findByConsumerId(int consumerId);

    @Select("select * from `order`")
    List<Order> list();

    List<User> findByUserId(int consumerId);

    /**
     * 根据订单状态查询订单
     *
     * @param status
     * @return
     */
    @Select("select * from `order` where status = #{status}")
    Page<OrderDeliveryVO> findByOrderStatus(int status);

    @Delete("delete from `order` where order_number = #{orderNumber}")
    void deleteByOrderNumber(String orderNumber);

    List<Order> findByCondition(OrderQuery orderQuery);

    List<Order> findByConditionSupplier(OrderQuery orderQuery);

    void updateOrder(Order order);

    //    @Select("select * from 'order' where oid = #{oid}")
    Order findOrderByOid(String orderNumber);

}
